package com.sunnay.vo.auth;

import com.sunnay.annotation.SunayField;
import com.sunnay.constant.StaticValueConstant;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
*@discrption: 存储于系统的用户信息
*@user:Gaby
*@createTime: 2021/1/25 17:17
*/
@Data
public class SystemUser implements Serializable {

    private static final long serialVersionUID = 6424780435132356834L;

    private String id;

    @SunayField(comment = "用户编号")
    private String userId;

    @SunayField(comment = "用户身份")
    private Integer userType = 0;

    @SunayField(comment = "客户端来源")
    private Integer client;

    @SunayField(comment = "在线标识 onlineKey")
    private String onlineKey;

    @SunayField(comment = "系统类型")
    private Integer systemType;

    @SunayField(comment = "微信ID")
    private String wxId;

    public String getOnlineKey() {
        if (StringUtils.isBlank(this.onlineKey)) {
            if (StringUtils.isBlank(this.id)) {
                return null;
            }
            String onlineKey = id + "_" + (StaticValueConstant.SourceEnum.isApp(client)? StaticValueConstant.SourceEnum.SOURCE_APP.getKey():client);
            if (this.systemType != null) {
                onlineKey = onlineKey + "_" + this.systemType;
            }
            this.onlineKey = onlineKey;
        }
        return this.onlineKey;
    }
}
